public without sharing class SSYASMResourceAjustmentController
{
     public Activity_Information__c ActivityInfo{get;set;}
     public CommonAttribute CommonAtt{get;set;}
     public String OutletName{get;set;}
     public String SelectedType{get;set;}
     public CommonMethod getCommonMethod;
     public CommonRecursionMethod getRecursionMethod;
     public List<String> KAETColumnList{get;set;}
     public  List<DynamicColumnEntry> KADynamicColumnEntryList{get;set;}
     public  List<DynamicColumnEntry> OTDynamicColumnEntryList{get;set;}
     
     public List<Activity_Competition_Brand_Detail__c> KACompetitionList{get;set;}
     public List<Activity_Competition_Brand_Detail__c> OTCompetitionList{get;set;}
     public List<String> OTETColumnList{get;set;}
      public Participator_Detail_Area__c parDetailArea;
     public List<SelectOption> ParticipatorKAList{get;set;}//参与列表中的KA

     public List<Resource_Allocation_Detail__c> kaResourceDetailList{get;set;}
     List<Resource_Allocation_Detail__c> otResourceDetailList;
     
     Set<string> kaOutletIdList;//ka门店Id列表
     Set<string> otOutletIdList;//ot门店Id列表
     public List<SelectOption> CityList{get;set;}//城市列表
     
     public Boolean IsDisplayForSubmit{get;set;}
     public Boolean IsDisplayForSave{get;set;}
     public Boolean IsDisplayForComfirmDate{get;set;}
     public string SubordinateUserId{get;set;}//获取当前用户下面的所有用户
     public List<id> SubordinateUserIdList{get;set;}//获取当前用户下面的所有用户
   //  public  List<KAMConfirmASMDate__c> kamConfirmAsmDateList{get;set;}   //是否被KAM确认
     public User user
     {
         get{return [select id,UserRegion__c from User where id=:UserInfo.getUserId()];}
     }

     public  List<SelectOption> TypleList
     {
         get
         {
             List<SelectOption> ListValue=new List<SelectOption>();  
             ListValue.add(new SelectOption('KA','KA'));
             ListValue.add(new SelectOption('OT','OT'));
             return ListValue;
         }
         set;
     }
     public String RecordId
     {
           get
           {
               return String.valueOf(System.currentPageReference().getParameters().get('id')).substring(0,15);  
           }
           set;
     }
     public List<AllocationResourceEntry> OTResourceList
     {
         get{return KAAndOTResourceList('OT');}
     }
     public List<AllocationResourceEntry> KAResourceList
     {
         get{return KAAndOTResourceList('KA');}
     }
    /* public User CurrentUser
     {
         get
         {
             return [select id,name,UserSubRegion__c from User where Id=:UserInfo.getUserId()];
         }
     }*/
    
     public SSYASMResourceAjustmentController()
     {
          LoadData();
     }
     
     public void LoadData()
     {
         getCommonMethod=new CommonMethod();
         if(CityList==NULL)
             CityList=new List<SelectOption>();
         else
             CityList.clear();
         
         if(ParticipatorKAList==NULL)
             ParticipatorKAList=new List<SelectOption>();
         else
             ParticipatorKAList.clear();
         
         CommonAtt=new CommonAttribute ();
         getRecursionMethod=new CommonRecursionMethod();
         
         //获取当前用户下的子用户SubordinateUserId 
             SubordinateUserIdList=new List<id>(getRecursionMethod.getASMBelowRoleId());
             SubordinateUserId ='';
               for(Id idString:SubordinateUserIdList)
               {
                   if(SubordinateUserId=='')
                       SubordinateUserId='\''+idString+'\'';
                    else
                    {
                        SubordinateUserId+=',';
                        SubordinateUserId+='\''+idString+'\'';
                    }
               }
      
         map<string,List<SelectOption>> KAAndCityList=getCommonMethod.getSubordinateCity(RecordId,SubordinateUserIdList);
         if(KAAndCityList!=NULL)
         {
             if(KAAndCityList.get('City')!=NULL)
                 CityList=KAAndCityList.get('City');
             if(KAAndCityList.get('KA')!=NULL)
                 ParticipatorKAList=KAAndCityList.get('KA');
         }
       
         IsDisplayForSave=false;
         IsDisplayForSubmit=false;
         IsDisplayForComfirmDate=false;
         
         otOutletIdList=new Set<string>();
         kaOutletIdList=new Set<string>();
         
            ActivityInfo=[Select Id,Name,  Activity_End_Date__c, Activity_Notice__c, Activity_Stage__c, Activity_Start_Date__c,IsNcOrNotForKA__c,IsNcOrNotForOT__c,
                                IsNcOrNotForRegion__c,Activity_Type_State__c, Activity_Type__c,Serial_Number__c FROM Activity_Information__c where id=: RecordId]; 
         
         //查出生效的审批记录
             List<Participator_Detail_Area__c> parDetailAreaList=[select id,Submit_ASM__c,Outlet_Amount__c,Approve_Type__c,Approve_Description__c from Participator_Detail_Area__c
                                      where Activity_Information__c=:RecordId  and Submit_ASM__c=:UserInfo.getUserId()  and IsActive__c=true limit 1];
            if(parDetailAreaList!=NULL && parDetailAreaList.size()>0)
                 parDetailArea=parDetailAreaList[0];    
                //查出该ASM是否已被KAM确认时间
         //  kamConfirmAsmDateList=new List<KAMConfirmASMDate__c>();
         /* if(parDetailArea!=NULL && parDetailAreaList.size()>0)
          {
                kamConfirmAsmDateList=[select id,ConfirmKAM__c,KAList__c from KAMConfirmASMDate__c 
                                                            where IsConfirm__c=true 
                                                            and Participator_Detail_Area__r.Submit_ASM__c=:user.id 
                                                            and Participator_Detail_Area__c=:parDetailArea.id and
                                                            Participator_Detail_Area__r.Activity_Information__c=:RecordId 
                                                            and Participator_Detail_Area__r.IsActive__c=true];
              
          }*/
          if(getCommonMethod.CheckSubmit())//检查ASM是否可以提交，只有直接汇报给RSM的ASM才可以提交
          {
                 if(ActivityInfo.Activity_Stage__c=='活动已取消')
                 {
                      IsDisplayForSubmit=false;
                       IsDisplayForSave=false;
                       IsDisplayForComfirmDate=false;
                 }  
                 else
                 {
                      Date StartDT=ActivityInfo.Activity_Start_Date__c;                   
                      if(Date.today()>= StartDT.addDays(-21))//开始活动前21天不可以调时间
                      {   
                           IsDisplayForSubmit=false;
                           IsDisplayForSave=false;
                           IsDisplayForComfirmDate=false;
                       }      
                       else
                       {                     
                            if(parDetailArea != NULL)
                            {
                                if(parDetailArea.Approve_Type__c=='ASM已提交'){
                                    IsDisplayForSubmit=false;
                                    IsDisplayForComfirmDate=false;    
                                    IsDisplayForSave=false;                            
                                }
                                if(parDetailArea.Approve_Type__c=='SRTM已审批' && parDetailArea.Approve_Description__c=='同意')
                                {
                                    IsDisplayForSubmit=true;
                                     IsDisplayForComfirmDate=true;
                                     IsDisplayForSave=true;
                                 }
                                 if( parDetailArea.Approve_Description__c=='拒绝')
                                  {
                                      IsDisplayForSubmit=true;
                                     IsDisplayForComfirmDate=false;
                                     IsDisplayForSave=true;
                                 }
                                   if(parDetailArea.Approve_Type__c=='ASM已确认时间')
                                 {
                                      IsDisplayForSubmit=false;
                                      IsDisplayForSave=false;
                                     IsDisplayForComfirmDate=false;                                                   
                                 }   
                            }
                            else
                            {
                                  IsDisplayForSubmit=true;
                                  IsDisplayForSave=true;
                                  IsDisplayForComfirmDate=false;
                            }
                       }
               }
         }
          kaResourceDetailList=new List<Resource_Allocation_Detail__c>();
          otResourceDetailList=new List<Resource_Allocation_Detail__c>();
         
         //ParticipatorKAList=getCommonMethod.ParticipatorKAList(RecordId,false);//取得用户ＫＡ列表
         
          if(CommonAtt.CitySelectedValue==NULL && CityList.size()>0)
             CommonAtt.CitySelectedValue=CityList[0].getValue();
          if(CommonAtt.KASelectedValue==NULL && ParticipatorKAList.size()>0)
              CommonAtt.KASelectedValue=ParticipatorKAList[0].getValue();
           
         List<ParticipatorArea__c> parAreaList=new List<ParticipatorArea__c>([select OT_Status__c from ParticipatorArea__c where Activity_Name__c=:RecordId 
                                                                                                                       and Region__c=:user.UserRegion__c and OT_Status__c!='SRTM已提交' and Type__c='OT']);
         if( parAreaList.size()>0)
         {
               IsDisplayForSubmit=false;
               IsDisplayForSave=false;
               IsDisplayForComfirmDate=false;
         }     
     //    CommonAtt=new CommonAttribute();
         if(CityList.size()>0 || ParticipatorKAList.size()>0)
         {
              LoadParticipatorOutletList('KA');//加载ＫＡ门店列表
              LoadParticipatorOutletList('OT');//加载OT门店列表  
             LoadCompetitionList('KA');//加载KA竞品信息
             LoadCompetitionList('OT');//加载OT竞品信息
         }
   }   
    
     public PageReference OutletQuery()
     {
         LoadParticipatorOutletList('KA');//加载ＫＡ门店列表
        LoadParticipatorOutletList('OT');//加载OT门店列表
        LoadCompetitionList('KA');//加载KA竞品信息
        LoadCompetitionList('OT');//加载OT竞品信息
         return null;
     }
     public void LoadParticipatorOutletList(string typeStr)
     {
             String filter=GetSqlFilter(typeStr); 
                 
            if(typeStr=='KA')   
            {
                 kaResourceDetailList=getCommonMethod.LoadOutletList(filter,RecordId);//加载门店列表
                 KAETColumnList=getCommonMethod.GetDynamicETColumnList(kaResourceDetailList);//获取列名
                 KADynamicColumnEntryList=getCommonMethod.GetDynamicEntryList(kaResourceDetailList);//获取门店列表  
            }
           else
           {
        
              otResourceDetailList=getCommonMethod.LoadOutletList(filter,RecordId);//加载门店列表
              OTETColumnList=getCommonMethod.GetDynamicETColumnList(otResourceDetailList);//获取列名
              OTDynamicColumnEntryList=getCommonMethod.GetDynamicEntryList(otResourceDetailList);//获取门店列表  
           }
           
     }
     
     public List<AllocationResourceEntry> KAAndOTResourceList(string typeStr)
     {  
         if(CommonAtt.CitySelectedValue==NULL)
             CommonAtt.CitySelectedValue=CommonAtt.AllCityList[0].getValue();
          if(CommonAtt.KASelectedValue==NULL)
              CommonAtt.KASelectedValue=CommonAtt.OutletKAList[0].getValue();
              
          String filter='';
              
          List<AllocationResourceEntry> option=new List<AllocationResourceEntry>();
           if(typeStr=='KA')
           {
               //KA是同一个城市同一个KA之间进行调整
               filter=' and Participator_Detail_Outlet__r.KA__c=\''+CommonAtt.KASelectedValue+'\''+
                                   ' and Participator_Detail_Outlet__r.City__c=\''+CommonAtt.CitySelectedValue+'\''+
                                   ' and Participator_Detail_Outlet__r.OutletResourceType__c=\''+typeStr+'\'';
               
             }
             else//同一个城市之间调整
             {
                    filter=' and Participator_Detail_Outlet__r.City__c=\''+CommonAtt.CitySelectedValue+'\''+
                                        ' and Participator_Detail_Outlet__r.OutletResourceType__c=\''+typeStr+'\'';
                 
             }   
             if(SubordinateUserId!=NULL && SubordinateUserId.length()>0)
                filter+=' and Participator_Detail_Outlet__r.OwnerId in ('+SubordinateUserId+')';
        //    filter+=' and Participator_Detail_Outlet__r.Activity_Stage__c=\'SRTM已提交\'';
             return getCommonMethod.LoadResourceAllcationListByOutlet(filter,RecordId);
     }
     //生成OT的竞品费用信息
   /*  public void GenerateCompetition()
     {
         List<Activity_Competition_Brand_Detail__c> cometitionList=new  List<Activity_Competition_Brand_Detail__c>();
         
           //检查OT是否有生成竞品费用信息,按区域生成,ASM只能看到自己有权限看的数据
        Integer countNumber=[select Count() from Activity_Competition_Brand_Detail__c 
                                                    where ActivityId__c=:RecordId and Activity_Competition_Brand_Information__r.Type__c='OT'];
        if(countNumber==0)
        {
            List<Participator_Detail_Outlet__c> parDetailList=[select id,OwnerId from Participator_Detail_Outlet__c
                                                                                          where  ActivityId__c=:RecordId and OutletResourceType__c='OT'];
                                                                                               
             for(Activity_Competition_Brand_Information__c activity:[select id from Activity_Competition_Brand_Information__c
                                                                                                    where Activity_Information__c=:RecordId and Type__c='OT'])
             {
                  for(Participator_Detail_Outlet__c par:parDetailList)
                  {
                      cometitionList.add(new Activity_Competition_Brand_Detail__c(Activity_Competition_Brand_Information__c=activity.Id,
                                                                                                                     Participator_Detail_Outlet__c=par.Id,
                                                                                                                     OwnerId=par.OwnerId));
                  }
             }    
             insert  cometitionList;                                                                   
        }
     }*/
     //加载竞品信息
     public void LoadCompetitionList(string typeStr)
     {
         String filter=GetSqlFilter(typeStr);
         String sql='select OutletName__c,SubmitASM__c,OutletId__c,Promotion_Type__c,Cost_Type__c,Competition_Cost_Source__c,'+
                            ' Money__c,Start_Date__c,End_Date__c,Display_Type__c,Participator_Detail_Outlet__r.Outlet_Name__r.OutletCode__c from Activity_Competition_Brand_Detail__c'+
                            '  where ActivityId__c=\''+RecordId +'\''+filter;
              //             throw new CustomException (sql);  
         if(typeStr=='KA')
         {
             KACompetitionList=Database.Query(sql);
         }
         else
         {
             OTCompetitionList=Database.Query(sql);
         }
     }
     
     public String GetSqlFilter(String typeStr)
     {
          if(CommonAtt.CitySelectedValue==NULL)
             CommonAtt.CitySelectedValue=CommonAtt.AllCityList[0].getValue();
          if(CommonAtt.KASelectedValue==NULL)
              CommonAtt.KASelectedValue=CommonAtt.OutletKAList[0].getValue();
              
           String filter=' and Participator_Detail_Outlet__r.City__c=\''+CommonAtt.CitySelectedValue+'\'';
        if(OutletName!=NULL)
            filter+=' and Participator_Detail_Outlet__r.Outlet_Name__r.Name like \'%'+OutletName+'%\'';
        if(CommonAtt.OutletTypeSelectedValue!='' && CommonAtt.OutletTypeSelectedValue!=NULL)
            filter+=' and Participator_Detail_Outlet__r.OutletType__c=\''+CommonAtt.OutletTypeSelectedValue+'\'';
        if(CommonAtt.ChannelSelectedValue!='' && CommonAtt.ChannelSelectedValue!=NULL)
            filter+=' and Participator_Detail_Outlet__r.Channel__c=\''+CommonAtt.ChannelSelectedValue+'\'';
        
        if(typeStr=='KA')   
            filter+=' and Participator_Detail_Outlet__r.KA__c=\''+CommonAtt.KASelectedValue+'\'';
         else
              filter+=' and Participator_Detail_Outlet__r.OutletResourceType__c=\'OT\'';
              
          //    filter+=' and Participator_Detail_Outlet__r.Activity_Stage__c=\'SRTM已提交\'';
          
        if(SubordinateUserId!=NULL && SubordinateUserId.length()>0)
            filter+=' and Participator_Detail_Outlet__r.OwnerId in ('+SubordinateUserId+')';
         return filter;
     }
    
     public PageReference SubmitActivity()
     {
         boolean flag=true;
         flag=CheckCreetOutletResource('KA',KADynamicColumnEntryList,flag,ActivityInfo);
         flag=CheckCreetOutletResource('OT',OTDynamicColumnEntryList,flag,ActivityInfo);
         if(!flag)
               throw new CustomException('非NC门店和关闭门店分配的资源必须为零');
               
         CheckOutletResource();
         IsDisplayForSubmit=false;
         IsDisplayForSave=false;
         
         Integer outletNumber=[select count() from Participator_Detail_Outlet__c where ActivityId__c=:RecordId and OwnerId in:SubordinateUserIdList];     
        
             Participator_Detail_Area__c approvalDetailArea=new Participator_Detail_Area__c();
             approvalDetailArea.Activity_Information__c=RecordId;
             approvalDetailArea.Approve_Type__c='ASM已提交';
             approvalDetailArea.Submit_ASM__c=UserInfo.getUserId();
             approvalDetailArea.Outlet_Amount__c=outletNumber;//门店总数
            
             insert approvalDetailArea;
     
          try
          {
               SaveData(approvalDetailArea.Id);
              updateAllRadAndCom(approvalDetailArea.Id);
          }
         catch(Exception ex)
         {
              ApexPages.addMessages(ex);
               return null;
         }
         //提交审批
          Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();   
          req1.setObjectId(approvalDetailArea.Id);
          Approval.ProcessResult result = Approval.process(req1);
          
          approvalDetailArea.ApprovalId__c=(String)result.getNewWorkitemIds().get(0);
          update approvalDetailArea;
          
          PageReference pr=new PageReference('/'+RecordId );
          pr.setRedirect(true);
         return pr;
     }
     public PageReference SaveActivity()
     {
         boolean flag=true;
         flag=CheckCreetOutletResource('KA',KADynamicColumnEntryList,flag,ActivityInfo);
         flag=CheckCreetOutletResource('OT',OTDynamicColumnEntryList,flag,ActivityInfo);
         if(!flag)
               throw new CustomException('非NC门店和关闭门店分配的资源必须为零');
         CheckOutletResource();
        SaveData(null);
         return null;
     }
     //提交时将ParticipatorDetailArea赋给所有资源明晰和竞品明细
     public void updateAllRadAndCom(String parId){
        //更改所以分配明细和竞品明细的关连
            List<Resource_Allocation_Detail__c>  radList=[select id,Participator_Detail_Area__c from Resource_Allocation_Detail__c where ActivityId__c=:RecordId and Participator_Detail_Outlet__r.OwnerId in:SubordinateUserIdList];            
             for(Resource_Allocation_Detail__c rad:radList)
             {
                 rad.Participator_Detail_Area__c=parId;
             }
             update radList;  
              List<Activity_Competition_Brand_Detail__c>  acbdList=[select id,SubmitASM__c from Activity_Competition_Brand_Detail__c where ActivityId__c=:RecordId and OwnerId in:SubordinateUserIdList];     
             for(Activity_Competition_Brand_Detail__c acbd:acbdList)
             {
                 acbd.SubmitASM__c=parId;
             }
             update acbdList;
     }
     public void SaveData(String parId)
     {
             //保存竞品信息
         //    if(parId!=NULL)
        //     {
                 for(Activity_Competition_Brand_Detail__c acbd:KACompetitionList)
                 {
                   //  if(acbd.Start_Date__c==NULL || acbd.End_Date__c==NULL || acbd.Money__c==NULL)
                    //     throw new CustomException('请填写好完整的竞品信息，开始时间、结束时间、金额为必填项');
                         
                  //   acbd.SubmitASM__c=parId;
                 }
                for(Activity_Competition_Brand_Detail__c acbd:OTCompetitionList)
                {
                   //  if(acbd.Start_Date__c==NULL || acbd.End_Date__c==NULL || acbd.Money__c==NULL)
                   //      throw new CustomException('请填写好完整的竞品信息，开始时间、结束时间、金额为必填项');
                         
                 //    acbd.SubmitASM__c=parId;
                 }
       //      }
             //保存调整好的门店分配数
             getCommonMethod.SaveAdjustmentResourceForOulet(OTDynamicColumnEntryList,otResourceDetailList,parId);//保存OT
             getCommonMethod.SaveAdjustmentResourceForOulet(KADynamicColumnEntryList,kaResourceDetailList,parId);//保存ＫＡ
             
             update KACompetitionList;
             update OTCompetitionList;
         
             //一旦点击保存之前审批的信息失效
             if(parDetailArea!=NULL)
             {
                 parDetailArea.IsActive__c=false;
                 update parDetailArea;
             }
             
             LoadData();
     }

     //判断当前
     public boolean CheckCreetOutletResource(String typeStr,List<DynamicColumnEntry> DynamicColumnEntryList,boolean flag,Activity_Information__c ActivityInfo){
      //
      boolean IsNc=false;
      if(typeStr=='KA'){
        if(ActivityInfo.IsNcOrNotForKA__c==true)
          IsNc=true;
      }
       if(typeStr=='OT'){
        if(ActivityInfo.IsNcOrNotForOT__c==true)
          IsNc=true;
      }
      if(typeStr=='Region'){
        if(ActivityInfo.IsNcOrNotForRegion__c==true)
          IsNc=true;
      }
      if(IsNc){
         for(DynamicColumnEntry d:DynamicColumnEntryList){
           if(d.WithoutNCOrNot==false){
              if(d.Resource1>0){
                 flag=false;
                 break;
              }
              if(d.Resource2>0){
                flag=false;
                break;
              }
               if(d.Resource3>0){
                flag=false;
                break;
                }
               if(d.Resource4>0){
                flag=false;
                break;
                }
               if(d.Resource5>0){
                flag=false;
                break;
                }
           }
         }
      }
      
        for(DynamicColumnEntry d:DynamicColumnEntryList){
        if(d.OutletStatus=='关闭'){
          if(d.Resource1>0){
            flag=false;
            break;
          }
           if(d.Resource2>0){
            flag=false;
            break;
          }
           if(d.Resource3>0){
            flag=false;
            break;
          }
           if(d.Resource4>0){
            flag=false;
            break;
          }
           if(d.Resource5>0){
            flag=false;
            break;
          }
          
        }
       }
       return flag;
     }
     //判断从NC转到非NC时资源必须为零,关闭门店资源也必须为零 
     public void CheckOutletResource()
     {
         string filter='';
         String pFilter='';
         string sql='select id from Resource_Allocation_Detail__c where ActivityId__c=:RecordId and Resource_Quantity_Number__c>0 and Participator_Detail_Outlet__r.Outlet_Name__r.With_NC_or_not__c=false';
         if(ActivityInfo.IsNcOrNotForKA__c)//判断从NC转到非NC时资源必须为零,关闭门店资源也必须为零 
             filter=' ReourceOutletType__c=\'KA\'';
         if(ActivityInfo.IsNcOrNotForOT__c)
         {
             if(filter!='')
                 filter+=' or ReourceOutletType__c=\'OT\'';
             else
                 filter+='  ReourceOutletType__c=\'OT\'';
         }   
           
         if(pFilter!='')
             pFilter+=' or Participator_Detail_Outlet__r.OutletResourceType__c=\'关闭\'';
         else
             pFilter+='  Participator_Detail_Outlet__r.OutletResourceType__c=\'关闭\'';
           
         if(pFilter!='')  
               sql+=' and ('+pFilter+')';
         if(filter!='')
             sql+=' and ('+filter+')';
       //   System.assert(false,sql);   
         List<Resource_Allocation_Detail__c> radList=Database.query(sql);  
         if(radList!=NULL && radList.size()>0)  
              throw new CustomException('非NC门店和关闭门店分配的资源必须为零');
     }
     public PageReference ConfirmDate()
     {
          IsDisplayForSave=false;
         IsDisplayForSubmit=false;
        
        // parDetailArea.Approve_Type__c='ASM已确认时间';
       //  update parDetailArea;
         
         update KACompetitionList;
         update OTCompetitionList;
         
         //发送邮件给KAM
          //获取用户信息
          /*
          if(parDetailArea.Approve_Type__c=='ASM第一次确认时间'){
            User u=getCommonMethod.getUserInfo();
            String BodyString=u.Name+'已调整了【'+ActivityInfo.Name+'】活动,请登陆凤凰系统进行确认时间,谢谢！';
            String subject='确认【'+ActivityInfo.Name+'】活动时间';
            EmailHander.SendMail(BodyString,getCommonMethod.getUserEmailAddress('KAM',RecordId),subject,'',null);
          }*/
         PageReference pr=new PageReference('/apex/ASMConfirmDatePage?id='+RecordId );
         pr.setredirect(true);   
         return pr;
     }
     //刷新最新的从非NC转NC的门店
     public PageReference RefreshOutlet()
     {
         getCommonMethod.RefreshOutlet(RecordId,ActivityInfo.Activity_Start_Date__c,'SSY',ActivityInfo.IsNcOrNotForOT__c,ActivityInfo.IsNcOrNotForKA__c,false);
         return null;
     }
}